﻿<?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes" encoding="utf-8" version="1.0" cdata-section-elements="failure" />

        <xsl:template match="/test-results/test-suite/results">
          <testsuites>

            <xsl:variable name="testsuites" select="test-suite"/>
            <xsl:for-each select="$testsuites">
              <testsuite name="{@name}" time="{@time}" tests="{count(descendant::test-case)}"
                  errors="" failures="{count(descendant::test-case/failure)}">

                <xsl:variable name="testcases" select="descendant::test-case"/>
                <xsl:for-each select="$testcases">
                  <xsl:variable name="asmClass">
                    <xsl:choose>
                      <xsl:when test="$testcases">
                        <xsl:value-of select="$testcases[1]/../../@name"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="@name"/>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:variable>
                  <testcase classname="{@name}" name="{substring-after(./@name, concat($asmClass,'.'))}" time="{./@time}">
                    <xsl:variable name="suite" select="."/>
                    <xsl:variable name="generalfailure" select="./failure"/>
                    <xsl:for-each select="$generalfailure">
                      <xsl:variable name="failstack" select="count(./failure/stack-trace/*) + count(./failure/stack-trace/text())"/>
                      <failure>
                        <xsl:choose>
                          <xsl:when test="$failstack &gt; 0 or not($generalfailure)">
                            MESSAGE: <xsl:value-of select="./failure/message"/>
                            +++++++++++++++++++
                            STACK TRACE: <xsl:value-of select="./failure/stack-trace"/>
                          </xsl:when>
                          <xsl:otherwise>
                            MESSAGE: <xsl:value-of select="$generalfailure/message"/>
                            +++++++++++++++++++
                            STACK TRACE: <xsl:value-of select="$generalfailure/stack-trace"/>
                          </xsl:otherwise>
                        </xsl:choose>
                      </failure>
                    </xsl:for-each>
                  </testcase>
                  </xsl:for-each>
                </testsuite>
</xsl:for-each>
          </testsuites>
    </xsl:template>

    </xsl:stylesheet>



Randy

randymay
     
    Posts: 7
    Joined: Sat Jun 14, 2008 10:13 am

Top

